@extends('admin.main')

@section('content')
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <h5>分类管理</h5>
        </div>
        <div class="ibox-content">
            <a class="btn btn-primary" id="classAdd" href="javascript:;">添加分类</a>
             <div class="hr-line-dashed"></div>
            <table id="tblDataList" class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>名称</th>
                        <th>活动数量</th>
                        <th width="100">操作</th>
                    </tr>
                </thead>
                <tbody>
                     @foreach($rows as $row)
                        <tr data-id="{{$row->id}}">
                            <td>{{$row->id}}</td>
                            <td>{{$row->name}}</td>
                            <td>{{$row->count}}</td>
                            <td>
                                <a href="javascript:;" class="m-r-xs btn btn-success btn-xs btn-del">
                                    删除
                                </a>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
            <div class="text-center pagination">
                {{$rows->links()}}
            </div>
        </div>
    </div>
</div>
@endsection

@section('pageheader')
@endsection
@section('pagescript')

<script>
    $("#side-menu li[rel='activity']").addClass("active")
    .find("ul").addClass("in")
    .find("li[rel='3']").addClass("active");
    $(function () {
        $(".btn-del").click(function(){
            var that = $(this).parents('tr').eq(0);
            var id = that.attr('data-id');
            $
            layer.confirm('确定删除此条记录吗？',{
                btn:['确定','取消']
            },function(){
                $.post('/admin/activity/class/del',{'id':id},function(data){
                    layer.msg('删除成功');
                    that.remove();
                }).fail(failure);
            },function(){
                layer.closeAll();
            });
        });

        $('#classAdd').click(function(){
              layer.prompt({title: '请输入分类名称', formType: 0}, function(text){
                  $.post('/admin/activity/class/insert',{'name':text},function(data){
                      layer.msg('添加成功');
                      window.location.reload();
                  }).fail(failure);
              });
        })
    })


</script>
@endsection
